#include "book.h"

namespace Books
{
	Book::Book(ISBN isbn, std::string auth, std::string name, Chrono::Date dd, Genre genre ,bool issued)
		:book_ISBN(isbn), book_author(auth), book_name(name), cr_registry_date(dd), book_genre(genre),
		book_issued(issued)
	{}

	void Book::set_state(bool newst)
	{
		if (newst && book_issued)
			throw Error("Book already issued");
		book_issued = newst;
	}


	bool operator == (const Book& b1, const Book b2)
	{
		return (b1.get_ISBN().get_value() == b2.get_ISBN().get_value());
	}
	bool operator != (const Book& b1, const Book b2)
	{
		return !(b1==b2);
	}

	ostream& operator << (ostream& outs, const Book& b)
	{
		return outs << b.get_ISBN()     << std::endl
			 << b.get_author()   << std::endl
			 << b.get_name()	 << std::endl
			 << "\u00A9 " << b.get_copyright_date() 
			 << b.get_genre()
			 << std::endl;
	}

}